package com.jlect.swebing.ui.client;

/**
 * The <code>Dimension</code> class encapsulates the width and
 * height of a component (in integer precision) in a single object.
 *
 * @author Sergey Kozmin
 * @since 10.11.2007
 */
public class Dimension {
    public final static Dimension ZERO_SIZE_DIMENSION = new ConstantDimension(0, 0);
    public final static Dimension MAX_SIZE_DIMENSION = new ConstantDimension(Integer.MAX_VALUE, Integer.MAX_VALUE); 

    public int width;
    public int height;

    public Dimension(int width, int height) {
        this.width = width;
        this.height = height;
    }

    public Dimension() {
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public static final class ConstantDimension extends Dimension {
        public void setWidth(int width) {
            throw new IllegalStateException("Could not change size. ");
        }

        public void setHeight(int height) {
            throw new IllegalStateException("Could not change size. ");
        }

        public ConstantDimension() {
            super();
        }

        public ConstantDimension(int width, int height) {
            super(width, height);
        }
    }
}
